package main

import (
	"log"
	"time"
)

func range3() {
	strings := []string{"hello", "world", "zack"}
	for _, str := range strings {
		log.Println("str is ", str)
		log.Println("str addr is ", &str)
		go func() {
			log.Println("in func str is ", str)
			log.Println("in func str addr is ", &str)
		}()
		time.Sleep(time.Second)
	}
}

func range2() {
	strings := []string{"hello", "world", "zack"}
	for _, str := range strings {
		log.Println("str is ", str)
		log.Println("str addr is ", &str)
		go func() {
			log.Println("in func str is ", str)
			log.Println("in func str addr is ", &str)
		}()
	}
}

func range1() {
	strings := []string{"hello", "world", "zack"}
	for _, str := range strings {
		go func() {
			log.Println("in func str is ", str)
		}()
	}
}

type student struct {
	Name string
	Age  int
}

func pase_student() {
	m := make(map[string]*student)
	stus := []student{
		{Name: "zhou", Age: 24},
		{Name: "li", Age: 23},
		{Name: "wang", Age: 22},
	}
	for _, stu := range stus {
		m[stu.Name] = &stu
	}

	for key, val := range m {
		log.Println("name is ", key)
		log.Println("age is ", val)
	}
}

func pase_student2() {
	m := make(map[string]student)
	stus := []student{
		{Name: "zhou", Age: 24},
		{Name: "li", Age: 23},
		{Name: "wang", Age: 22},
	}
	for _, stu := range stus {
		m[stu.Name] = stu
	}

	for key, val := range m {
		log.Println("name is ", key)
		log.Println("age is ", val)
	}
}

func main() {
	// range3()
	// time.Sleep(time.Second)
	// str := "Hello"
	// log.Println(str[0])
	// log.Println(str[0:1])
	//str[0] = 'g'
	// pase_student()
	pase_student2()
}
